package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.PublishMapper;
import com.digital.smartgrow.dto.title.Publish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class PublishServiceImpl implements PublishService{


    @Autowired
    PublishMapper publishMapper;

    @Override
    @Transactional
    public List<Publish> findList(Publish publish) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", publish.getIdcard());
        queryWrapper.eq("status", 0);
        return publishMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void delete(Publish publish) {
        Publish publish1  = new Publish();
        Date date = new Date();
        publish1.setStatus(1).setId(publish.getId()).setTime(date);
        publishMapper.updateById(publish1);
    }
}
